Sampling the source video |
Source video sampling allows a filter to pick a number of frames from its source to determine the characteristics of the incoming video. This is useful, for instance, to display a histogram of the input so the user can adjust contrast and brightness.
How the sampling interface works |
Video sampling requires the use of active preview and is thus attached to the IFilterPreview interface, made available through the fa->ifp member. There are three sampling functions:
Use SetSampleCallback() to give VirtualDub a callback function to accept frames for sampling. The callback has this prototype:
void FilterPreviewSampleCallback(VFBitmap *, long lFrame, long lCount, void *pData);
Once the callback is set up, call SampleCurrentFrame() to sample the frame currently being previewed by the user, or SampleFrames() to sample parts of the entire video. In the latter case, the user will be presented with a dialog box asking whether to sample the entire video, all keyframes, or one keyframe per second of video. SampleCurrentFrame() returns true if a frame was sampled, and SampleFrames() returns the total number of frames sampled, or -1 on error.
The preview window must be up before calling either function. Otherwise, SampleCurrentFrame() returns false, and SampleFrames() returns -1. Usually, you will want to install a button callback to disable sampling buttons when the preview window is not up.
Hints |
VirtualDub external filter SDK 1.05 | ©1999-2001 Avery Lee <phaeron@virtualdub.org> |